<?php
if(!defined('SABLOG_ROOT')) {
	exit('Access Denied');
}

if ($stats['comment_count']) {
	$commentlist_num = intval($options['commentlist_num']);
	if($page) {
		$start_limit = ($page - 1) * $commentlist_num;
	} else {
		$start_limit = 0;
		$page = 1;
	}
	$multipage = multi($stats['comment_count'], $commentlist_num, $page, $comments_url);
	$query = $DB->query("SELECT 
	c.articleid,c.author,c.url,c.email,c.dateline,c.content,a.alias,a.title
	FROM {$db_prefix}comments c
	LEFT JOIN {$db_prefix}articles a ON a.articleid = c.articleid
	WHERE a.visible='1' AND c.visible='1' ORDER BY commentid DESC LIMIT $start_limit, $commentlist_num");

	$commentdb=array();
	while ($comment=$DB->fetch_array($query)) {
		$comment['article_url'] = getpermalink($comment['articleid'], $comment['alias'], 0, sadate('Y/m/d',$article['dateline']));

		//分解邮件地址并采用javascript输出
		if ($comment['url']) {
			$comment['author'] = '<a href="'.$comment['url'].'" target="_blank">'.$comment['author'].'</a>';
		}
		$comment['content'] = html_clean($comment['content']);
		$comment['dateline'] = sadate($options['comment_timeformat'], $comment['dateline']);
		$comment['avataraddress'] = md5( $comment['email'] );
		$commentdb[]=$comment;
	}
	unset($comment);
	$DB->free_result($query);
}
$pagefile = 'comments';
$options['title'] = settitle('所有评论');

?>